<?php
defined('IN_ADMIN') or exit('No permission resources.');
$show_validator = true;include $this->admin_tpl('header_v2.0','admin');
?>

<!----> <div id="content"> 
    <div class="row">
        <article id="widget-grid" class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
            <div class="well well-sm">
                <a class="btn btn-primary" href="index.php?m=shuafen&c=industry&a=add&pid=0"></i>&nbsp;添加一级行业</a>
             </div>
             <div class="jarviswidget jarviswidget-color-darken" id="list_<?php echo $_GET['menuid']?>" data-widget-editbutton="false"data-widget-togglebutton="false"  data-widget-deletebutton="false" data-widget-fullscreenbutton="false">
                <header>
                      <span class="widget-icon"> <i class="fa fa-table txt-color-white"></i> </span>
                     <h2>添加行业</h2>
                </header>
                <div>
                    <div class="widget-body no-padding">
                            <div class ="table-content">
                                <table width="100%" cellspacing="0" class="table  pinned table-bordered  table-striped table-condensed ">
                                    <thead>
                                        <tr>
                                            <th>行业名称</th>
                                            <th>级别</th>
                                            <th>操作</th>
                                        </tr>
                                    </thead>
                                </table>
                                <table id="industry" width="100%" cellspacing="0" class="table table-bordered  table-striped table-condensed table-hover">
                                    <thead>
                                        <tr>    
                                            <th>行业名称</th>
                                            <th>级别</th>
                                            <th>操作</th>
                                        </tr>
                                    </thead>
                                    <tbody> 

                                        <?php foreach($industry_data as $data){?>
                                            <tr data-tt-id="<?php echo $data['id']?>" data-tt-parent-id="<?php echo $data['pid']?>">
                                                <td><?php echo $data['industry_name']?></td>
                                                <td>一级行业</td>
                                                <td>
                                                    <div class="btn-group">
                                                      <a class="btn btn-default" href="index.php?m=shuafen&c=industry&a=edit&id=<?php echo $data['id'] ?>" >
                                                          <i class="fa fa-info"></i> 修改
                                                      </a>

                                                      <a class="btn btn-default" href="index.php?m=shuafen&c=industry&a=add&pid=<?php echo $data['id'] ?>&pid_name=<?php echo $data['industry_name'];?>" class="" ><i class="fa fa-square"></i> 添加子行业</a>

                                                        <a class="btn btn-default" href="javascript:void(0);" onclick="industry_del(this,<?php echo $data['id']?>)"><i class="fa fa-trash-o"></i> 删除</a>
                                                    </div>
                                                </td>
                                            </tr>
                                            <?php if(isset($data['son'])){ foreach($data['son'] as $data_1){?>
                                                <tr data-tt-id="<?php echo $data_1['id']?>" data-tt-parent-id="<?php echo $data_1['pid']?>">
                                                    <td><?php echo $data_1['industry_name']?></td>
                                                    <td>二级行业</td>
                                                    <td>
                                                      <div class="btn-group">
                                                          <a class="btn btn-default" href="index.php?m=shuafen&c=industry&a=edit&id=<?php echo $data_1['id'] ?>" >
                                                              <i class="fa fa-info"></i> 修改
                                                          </a>
                                                           <a  class="btn btn-default" href="index.php?m=shuafen&c=industry&a=add&pid=<?php echo $data_1['id'] ?>&pid_name=<?php echo $data_1['industry_name'];?>" class="" ><i class="fa fa-square"></i> 添加子行业</a>
                                                           <a class="btn btn-default" href="javascript:void(0);" onclick="industry_del(this,<?php echo $data_1['id']?>)"><i class="fa fa-trash-o"></i> 删除</a>

                                                      </div>
                                                    </td>
                                                </tr>
                                                <?php if(isset($data_1['son'])){ foreach($data_1['son'] as $data_2){?>
                                                    <tr data-tt-id="<?php echo $data_2['id']?>" data-tt-parent-id="<?php echo $data_2['pid']?>">
                                                        <td><?php echo $data_2['industry_name']?></td>
                                                        <td>三级行业</td>
                                                    <td>
                                                      <div class="btn-group">
                                                          <a class="btn btn-default" href="index.php?m=shuafen&c=industry&a=edit&id=<?php echo $data_2['id'] ?>" >
                                                              <i class="fa fa-info"></i> 修改
                                                          </a>
                                                                   <a href="javascript:void(0);"  class="btn btn-default" onclick="industry_del(this,<?php echo $data_2['id']?>)"><i class="fa fa-trash-o"></i> 删除</a>

                                                      </div>
                                                    </td>
                                                    </tr>
                                                <?php }}?>
                                            <?php }}?>
                                        <?php }?>
                                        

                                        
                                     </tbody>
                                </table>
                            </div>
                    </div>
                </div>
             </div>
        </article>
    </div>
</div> <!---->

 <!--<div><a href="index.php?m=shuafen&c=industry&a=add&pid=0">添加一级行业</a></div>
<table id="industry">
    <thead>
        <tr>
            <th>行业名称</th>
            <th>级别</th>
            <th>操作</th>
        </tr>
    </thead>
    <tbody>
    <?php foreach($industry_data as $data){?>
        <tr data-tt-id="<?php echo $data['id']?>" data-tt-parent-id="<?php echo $data['pid']?>">
            <td><?php echo $data['industry_name']?></td>
            <td>一级行业</td>
            <td>
                <a href="index.php?m=shuafen&c=industry&a=edit&id=<?php echo $data['id'] ?>">修改</a>
                |<a href="index.php?m=shuafen&c=industry&a=add&pid=<?php echo $data['id'] ?>&pid_name=<?php echo $data['industry_name'];?>">添加子行业</a>
                ||<a href="javascript:;" onclick="industry_del(this,<?php echo $data['id']?>)" >删除</a>
            </td>
        </tr>
        <?php if(isset($data['son'])){ foreach($data['son'] as $data_1){?>
            <tr data-tt-id="<?php echo $data_1['id']?>" data-tt-parent-id="<?php echo $data_1['pid']?>">
                <td><?php echo $data_1['industry_name']?></td>
                <td>二级行业</td>
                <td>
                    <a href="index.php?m=shuafen&c=industry&a=edit&id=<?php echo $data_1['id'] ?>">修改</a>
                    |<a href="index.php?m=shuafen&c=industry&a=add&pid=<?php echo $data_1['id'] ?>&pid_name=<?php echo $data_1['industry_name'];?>">添加子行业</a>
                    |<a href="javascript:;" onclick="industry_del(this,<?php echo $data_1['id']?>)" >删除</a>
                </td>
            </tr>
            <?php if(isset($data_1['son'])){ foreach($data_1['son'] as $data_2){?>
                <tr data-tt-id="<?php echo $data_2['id']?>" data-tt-parent-id="<?php echo $data_2['pid']?>">
                    <td><?php echo $data_2['industry_name']?></td>
                    <td>三级行业</td>
                    <td>
                        <a href="index.php?m=shuafen&c=industry&a=edit&id=<?php echo $data_2['id'] ?>">修改</a>
                        |<a href="javascript:;" onclick="industry_del(this,<?php echo $data_2['id']?>)" >删除</a>

                    </td>
                </tr>
            <?php }}?>
        <?php }}?>
    <?php }?>
    </tbody>
</table> -->
<script>
$(function(){
    $("#industry").treetable({ expandable: true });
    // $("#industry  tbody").on("mousedown", "tr", function() {
    //     $(".selected").not(this).removeClass("selected");
    //     $(this).toggleClass("selected");

    // });

});
function industry_del(obj,id){
    window.top.art.dialog({content:'删除行业将删除其子行业！', fixed:true, style:'confirm', id:'del'},
        function(){
            $.get('index.php?m=shuafen&c=industry&a=del&id='+id+'&pc_hash=<?php echo $_SESSION['pc_hash']?>',function(data){
                if(data){
                    $(obj).parent().parent().fadeOut("slow");
                    window.location="index.php?m=shuafen&c=industry&a=init&pc_hash=<?php echo $_SESSION['pc_hash']?>";
                }
            })

        },
        function(){});
};
</script>
</body>
<script src="<?php echo PLUGIN_STATICS_PATH?>treetable/jquery.treetable.js"></script>
</html>
